package br.com.healthy.model.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import br.com.healthy.model.entity.Patient;
import br.com.healthy.model.entity.Dentist;;
/**
 * @author Dieb
 *
 */
public class Contract {

private int id;
	
	private Patient contracting;
	
	private Dentist engaged;
	
	private Date dateCriation;
	
	private Date dateExpiration;
	
	private List<Payment> payments;
	
	public Contract(Patient contracting, Dentist engaged,
			Date dateCriation, Date dateExpiration) {
		this();
		this.contracting = contracting;
		this.engaged = engaged;
		this.dateCriation = dateCriation;
		this.dateExpiration = dateExpiration;
	
	}

	public Contract() {
		payments = new ArrayList<Payment>();
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the contracting
	 */
	public Patient getContracting() {
		return contracting;
	}

	/**
	 * @param contracting the contracting to set
	 */
	public void setContracting(Patient contracting) {
		this.contracting = contracting;
	}

	/**
	 * @return the engaged
	 */
	public Dentist getEngaged() {
		return engaged;
	}

	/**
	 * @param engaged the engaged to set
	 */
	public void setEngaged(Dentist engaged) {
		this.engaged = engaged;
	}

	/**
	 * @return the dateCriation
	 */
	public Date getDateCriation() {
		return dateCriation;
	}

	/**
	 * @param dateCriation the dateCriation to set
	 */
	public void setDateCriation(Date dateCriation) {
		this.dateCriation = dateCriation;
	}

	/**
	 * @return the dateExpiration
	 */
	public Date getDateExpiration() {
		return dateExpiration;
	}

	/**
	 * @param dateExpiration the dateExpiration to set
	 */
	public void setDateExpiration(Date dateExpiration) {
		this.dateExpiration = dateExpiration;
	}

	/**
	 * @return the payments
	 */
	public List<Payment> getPayments() {
		return payments;
	}

	/**
	 * @param payments the payments to set
	 */
	public void setPayments(List<Payment> payments) {
		this.payments = payments;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((contracting == null) ? 0 : contracting.hashCode());
		result = prime * result
				+ ((dateCriation == null) ? 0 : dateCriation.hashCode());
		result = prime * result
				+ ((dateExpiration == null) ? 0 : dateExpiration.hashCode());
		result = prime * result + ((engaged == null) ? 0 : engaged.hashCode());
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Contract other = (Contract) obj;
		if (contracting == null) {
			if (other.contracting != null)
				return false;
		} else if (!contracting.equals(other.contracting))
			return false;
		if (dateCriation == null) {
			if (other.dateCriation != null)
				return false;
		} else if (!dateCriation.equals(other.dateCriation))
			return false;
		if (dateExpiration == null) {
			if (other.dateExpiration != null)
				return false;
		} else if (!dateExpiration.equals(other.dateExpiration))
			return false;
		if (engaged == null) {
			if (other.engaged != null)
				return false;
		} else if (!engaged.equals(other.engaged))
			return false;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Contract [id=").append(id).append(", contracting=")
				.append(contracting).append(", engaged=").append(engaged)
				.append(", dateCriation=").append(dateCriation)
				.append(", dateExpiration=").append(dateExpiration)
				.append(", payments=").append(payments).append("]");
		return builder.toString();
	}
	
}
